<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<!--#    Copyright 2011 Tri-County Electric Cooperative, St. Matthews, South Carolina
#    This file is part of COOPIP.
#    COOPIP is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#    COOPIP is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#    You should have received a copy of the GNU General Public License
#    along with COOPIP.  If not, see <http://www.gnu.org/licenses/>.-->

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>Dispatch Board</title>
  <link rel="stylesheet" type="text/css" href="/style.css" />
</head>
<body style="background-color: tan;">
  <b id = "timeoutindicator", style="float:right;">Initializing</b>

  <div id="meterping_wrap">
  </div>

  <script src="/jquery.js"></script>
  <script>
      function reloadExternal() {
          //single connection limit more useful during testing, when intervals are shorter
          if (RequestInProgress != true){
              RequestInProgress = true;
              $("#meterping_wrap").load("/coopip/dispatch/display/meterping/data/");
              RequestInProgress = false;
          }
      }

      function delayThenReload() {
          window.setInterval(reloadExternal, 15000);
      }

      //default for .load() timeout is 0, change in global settings
      $.ajaxSetup({
          timeout:2000,
          success: function(XMLHTTPResponse, Status){ $("#timeoutindicator").text(""); },
          error: function(XMLHTTPRequest, Status){ $("#timeoutindicator").text("ERROR: Connection Lost"); }
      });
      var RequestInProgress = false;
      reloadExternal();
      $(window).load(delayThenReload);      
  </script>

</body>
</html>
